#pragma once
//#include "scene.h"
#include "Model.h"
#include "scene.h"
#include "camera.h"
#include "vec.h"
#include "mat.h"
#include <string>


using namespace std;

class MeshModel : public Model
{
protected :
	MeshModel(Renderer * r):m_renderer(r),m_origin(vec4(0,0,0,1)){ }
	vector<vec3> _vertices;
	vector<vec3> _normals;
	vec3 boundingBoxMin;
	vec3 boundingBoxMax;
	GLfloat modelDiameter;
	mat4 _world_transform;
	mat4 _camera_transform;
	mat3 _normal_transform;
	vec4 m_origin;
	Renderer * m_renderer;
	Camera * m_camera;
	mat4 m_cameraReversalMatrix;
	void ApplyTransformation(const mat4 & m);
public:
	MeshModel(string fileName);
	virtual ~MeshModel(void);
	void loadFile(string fileName);
	virtual void draw();
	void ScaleMe(const GLfloat & x, const GLfloat & y, const GLfloat & z);
	void SetRenderer(Renderer * r) { m_renderer = r;}
	void TranslateModel(const GLfloat & x,const GLfloat & y,const GLfloat & z);
	void SpinModel( const GLfloat & x_angle, const GLfloat & y_angle, const GLfloat & z_angle);
	void SetCamera(Camera * c);
	void SetNormalTransform(const mat3 & n) { this->_normal_transform = n; }
	inline void RotateAboutX(const GLfloat & angle) { ApplyTransformation(RotateX(angle)); }
	inline void RoateteAboutY(const GLfloat & angle) { ApplyTransformation(RotateY(angle)); }
	inline void RotateAboutZ(const GLfloat & angle) { ApplyTransformation(RotateZ(angle)); }
	inline vec4 getOrigin() const { return m_origin; }
	vec4 getOriginInWorld() const;
	void Centralize();
	void Shrink();
};
